﻿/*
public var images:XMLList;
		public var currentImage:XML;
		public var currentTitle:String;
		public var currentFile:String;
		
		public function SlideshowModel()
		{
			
		}
		
		override protected function updateData():void
		{
			currentImage = images[currentIndex];
			totalItems = images.length();
			currentTitle = currentImage.title;
			currentFile = currentImage.file;
		}
*/

/**
 *
 * @title: Basic MVC Framework, View Class
 * @author: 
 * @license: 
 * @updated: 29/07/2010
 *
 * @version	1.0 
 */

package com.mediagallary.view {

	import com.mediagallary.model.*;
	import com.mediagallary.controller.*;
	import com.mediagallary.view.*;
	//import com.mediagallary.events.CustomEvent;

	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import flash.display.MovieClip;
	
	/**
	 * Basic View class in Model/View/Controller triad.
	 */
	public class View extends MovieClip{
		
		private var _model:Model;
		private var _controller:Controller;
		
		public function View(m:Model, c:Controller) {
			// Set the model.
			model = m;
			// If a controller was supplied, use it. Otherwise let the first
			// call to getController() create the default controller.
			if (c !== null) {
				controller = c;
			}
		} 
		
		/**
		 * Returns the default controller for this view.
		 */
		public function defaultController(model:EventDispatcher):Controller {
			return null;
		}


		/**
		 * Sets the controller for this view.
		 */
		public function set controller(c:Controller):void {
			_controller = c;
			//getController(null).setView(this);
		}

		/**
		 * Returns this view's controller.
		 */
		public function get controller():Controller {
			// If a controller hasn't been defined yet...make one. 
			return _controller;
		}

		public function set model(m:Model):void
		{
			trace("View set model: ")
			_model = m;
			_model.addEventListener(Model.MODEL_CHANGE, update);
			_model.addEventListener(Model.UPDATE, loaded);
		}
		
		public function get model():*
		{
			return _model;
		}
		
		/**
		 * An empty Observer update() method. 
		 * Subclasses of AbstractView will provide
		 * a concrete implementation for this method
		 * and update the view applicably
		 */
		public function loaded(event:Event = null):void
		{
			
		}
		 
		public function update(event:Event = null):void
		{
			
		}
	}
}